import { Injectable } from '@nestjs/common';
import type { IAuditContext } from '@nbase/db';
import { RequestContextService } from '../services/request-context.service';

/**
 * 审计上下文适配器
 * 
 * 将 RequestContextService 适配给 @nbase/db 使用
 * 实现了 IAuditContext 接口
 */
@Injectable()
export class AuditContextAdapter implements IAuditContext {
  constructor(private readonly requestContext: RequestContextService) {}

  /**
   * 获取当前用户 ID
   * 从 ClsService（nestjs-cls）中获取
   */
  getUserId(): string | undefined {
    return this.requestContext.getCurrentUserId();
  }
}


